<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{asset('/css/web/user/address.css')}}">
    <script src="{{asset('/js/web/user/address.js')}}"></script>
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<style type="text/css">
    .colw2 a{
        padding-right: 10px;
    }

</style>
<div class="base_member_content">
   
    <div class="w1200">
        @include('web.layout.buyer_nav')
        <div class="nav_right flr">
            <div class="base_content">
                <div class="line_title">发票管理</div>
                <div class="address-data">
                    <div class="tit fl">已保存发票信息</div>
                   
                    <a href="{{url('/member/inovce')}}" id="address_add">+新增发票信息</a>
            
                </div>
                <table border="0" cellspacing="0" cellpadding="0" class="address-tbl">
                    <thead>
                    <tr>
                        <th class="col-name">发票类型</th>
                        <th class="col-phone">发票抬头</th>
                        <th class="col-address">税号</th>
                        <th class="col-colw1">状态</th>
                        <th class="colw1">操作</th>
                        <th class="colw2">备注</th>
                    </tr>
                    </thead>
                    <tbody>
                        <?php if(!empty($data)){ foreach ($data as $key => $value) { ?>
                        <tr>
                            <td class="col-name">{{$value['invoice_type']}}</td>
                            <td class="col-phone">{{$value['invoice_title']}}</td>
                            <td class="col-address">{{$value['tax_code']}}</td>
                            <?php if(!empty($value['is_default'])){?>
                            <td class="colw1">默认发票</td>
                            <?php }else{?>
                            <td class="colw1"></td>
                            <?php }?>
                            <td class="colw2">
                                <a href="javascript:;" data-id="{{$value['user_invoice_id']}}" class="js-default">设为默认</a>
                                <a href="{{url('/member/inovce_create?id=')}}{{$value['user_invoice_id']}}">编辑</a>
                                <a href="javascript:;" data-id="{{$value['user_invoice_id']}}" class="js-remove">删除</a>
                            </td>
                            <td>{{$value['remark']}}</td>
                        </tr>
                        <?php }}?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@include('web.layout.footer')
<script>
    $(function () {
        $('.js-remove').click(function () {
            if (confirm('确认要删除这条地址记录吗？')) {
                var id = $(this).attr('data-id');
                $.ajax({
                    url: 'inovce_del',
                    type: 'POST',
                    dataType: 'json',
                    data: {'_token':"{{csrf_token()}}",'id':id},
                    success:function(data){
                        if(data.code==0){
                            window.location.reload();
                        }else{
                            layer.alert(data.message,{icon: 1});
                        }
                    }
                });
                
            }
        });
        $('.js-default').click(function () {
            var id = $(this).attr('data-id');
            $.ajax({
                url: 'inovce_default',
                type: 'POST',
                dataType: 'json',
                data: {'_token':"{{csrf_token()}}",'id':id},
                success:function(data){
                    if(data.code==0){
                        window.location.reload();
                    }else{
                        layer.alert(data.message,{icon: 1});
                    }
                }
            });
                
        });
    });
</script>
</body>
</html>